package com.shanyin.framework.member.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.shanyin.framework.common.base.ResponseData;
import com.shanyin.framework.member.service.SysUserService;

/***
 ** @category 请用一句话来描述其用途...
 ** @author qing.yunhui
 ** @email: 280672161@qq.com
 ** @createTime: 2018年5月23日下午5:31:25
 **/
@RestController
@RequestMapping(SysUserController.ACTION_PATH)
public class SysUserController {
	
	private final Logger logger = LoggerFactory.getLogger(getClass());
	
    final static String ACTION_PATH="/member/sys/user";
	
   /* @Autowired
    private DiscoveryClient client;*/
    
    @Autowired
    private SysUserService sysUserService;
    
    /**
     * <p>注册</p>
     * @param phone 注册手机号
     * @param password 密码
     * @param registerChannel 注册渠道
     * @param invitationCode  邀请码
     * */
    @RequestMapping(value = "/registered", method = RequestMethod.GET)
    public ResponseData registered(String phone,String password,String registerChannel,String invitationCode) {
    	logger.info("===============>开始调用注册接口...");
    	ResponseData responseData=sysUserService.registered(phone, password, registerChannel, invitationCode);
    	logger.info("===============>调用注册接口完毕...");
        return responseData;
    }
    
    /**
     * <p>登陆[支持手机号|邮箱]</p>
     * @param phone 手机号
     * @param password 密码
     * @param isPhone true:手机号登陆、false:邮箱登陆
     * */
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public ResponseData login(String phone,String password,boolean isPhone) {
    	logger.info("===============>开始调用登陆接口...");
    	ResponseData responseData=sysUserService.login(phone, password,isPhone);
    	logger.info("===============>调用登陆接口完毕...");
        return responseData;
    }
    
}
